﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
using System.Linq;

namespace Chess.Common.Network
{
    public sealed class SerializedNetworkReader : INetworkReader
    {
        private XmlSerializer _serializer { get; set; }
        private StreamReader _reader { get; set; }

        public SerializedNetworkReader(StreamReader reader)
        {
            _serializer = NetworkUtilities.BuildSerializer();
            _reader = reader;
        }

        public NetworkData Read()
        {
            return ((NetworkPacket)_serializer.Deserialize(_reader)).Data;
        }
    }
}
